/*     */ package com.zimbra.cs.mailbox;
/*     */ 
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.cs.db.DbMailItem;
/*     */ import com.zimbra.cs.index.SortBy;
/*     */ import java.util.Collections;
/*     */ import java.util.List;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class VirtualConversation
/*     */   extends Conversation
/*     */ {
/*     */   VirtualConversation(Mailbox mbox, Message msg)
/*     */     throws ServiceException
/*     */   {
/*  34 */     this(mbox, wrapMessage(msg));
/*     */   }
/*     */   
/*     */   VirtualConversation(Mailbox mbox, MailItem.UnderlyingData data) throws ServiceException {
/*  38 */     this(mbox, data, false);
/*     */   }
/*     */   
/*     */   VirtualConversation(Mailbox mbox, MailItem.UnderlyingData data, boolean skipCache) throws ServiceException {
/*  42 */     super(mbox, data, skipCache);
/*  43 */     if (this.mData.type != MailItem.Type.VIRTUAL_CONVERSATION.toByte()) {
/*  44 */       throw new IllegalArgumentException();
/*     */     }
/*     */   }
/*     */   
/*     */   public int getMessageId() {
/*  49 */     return -this.mId;
/*     */   }
/*     */   
/*     */   boolean loadSenderList() throws ServiceException
/*     */   {
/*  54 */     this.mSenderList = new SenderList(getMessage());
/*  55 */     return false;
/*     */   }
/*     */   
/*     */   SenderList recalculateMetadata(List<Message> msgs) throws ServiceException
/*     */   {
/*  60 */     Message msg = (Message)msgs.get(0);
/*  61 */     this.mData = wrapMessage(msg);
/*  62 */     this.mExtendedData = MetadataCallback.duringConversationAdd(null, msg);
/*  63 */     return getSenderList();
/*     */   }
/*     */   
/*     */   Message getMessage() throws ServiceException
/*     */   {
/*  68 */     return this.mMailbox.getMessageById(getMessageId());
/*     */   }
/*     */   
/*     */   public List<Message> getMessages(SortBy sort, int limit) throws ServiceException
/*     */   {
/*  73 */     return Collections.singletonList(getMessage());
/*     */   }
/*     */   
/*     */   static VirtualConversation create(Mailbox mbox, Message msg) throws ServiceException {
/*  77 */     VirtualConversation vconv = new VirtualConversation(mbox, msg);
/*  78 */     vconv.markItemCreated();
/*  79 */     return vconv;
/*     */   }
/*     */   
/*     */   private static MailItem.UnderlyingData wrapMessage(Message msg) {
/*  83 */     MailItem.CustomMetadata.CustomMetadataList extended = MetadataCallback.duringConversationAdd(null, msg);
/*     */     
/*  85 */     MailItem.UnderlyingData data = new MailItem.UnderlyingData();
/*  86 */     data.id = (-msg.getId());
/*  87 */     data.type = MailItem.Type.VIRTUAL_CONVERSATION.toByte();
/*  88 */     data.folderId = 9;
/*  89 */     data.setSubject(msg.getSubject());
/*  90 */     data.date = ((int)(msg.getDate() / 1000L));
/*  91 */     data.modMetadata = msg.getSavedSequence();
/*  92 */     data.modContent = msg.getSavedSequence();
/*  93 */     data.size = 1L;
/*  94 */     data.unreadCount = msg.getUnreadCount();
/*  95 */     data.setFlags(msg.getInternalFlagBitmask());
/*  96 */     data.setTags(new Tag.NormalizedTags(msg.getTags()));
/*  97 */     data.metadata = encodeMetadata(DEFAULT_COLOR_RGB, 1, 1, extended, new SenderList(msg));
/*  98 */     return data;
/*     */   }
/*     */   
/*     */   void open(String hash) throws ServiceException
/*     */   {
/* 103 */     DbMailItem.openConversation(hash, getMessage());
/*     */   }
/*     */   
/*     */   void close(String hash) throws ServiceException
/*     */   {
/* 108 */     DbMailItem.closeConversation(hash, getMessage());
/*     */   }
/*     */   
/*     */   void alterTag(Tag tag, boolean add) throws ServiceException
/*     */   {
/* 113 */     getMessage().alterTag(tag, add);
/*     */   }
/*     */   
/*     */   protected void inheritedTagChanged(Tag tag, boolean add) throws ServiceException
/*     */   {
/* 118 */     if ((tag == null) || (add == isTagged(tag))) {
/* 119 */       return;
/*     */     }
/* 121 */     markItemModified((tag instanceof Flag) ? 4 : 2);
/* 122 */     tagChanged(tag, add);
/*     */   }
/*     */   
/*     */   protected void inheritedCustomDataChanged(Message msg, MailItem.CustomMetadata custom) throws ServiceException
/*     */   {
/* 127 */     markItemModified(524288);
/* 128 */     this.mExtendedData = MetadataCallback.duringConversationAdd(null, msg);
/*     */   }
/*     */   
/*     */   void addChild(MailItem child) throws ServiceException
/*     */   {
/* 133 */     throw MailServiceException.CANNOT_PARENT();
/*     */   }
/*     */   
/*     */   void removeChild(MailItem child) throws ServiceException
/*     */   {
/* 138 */     if (child.getId() != getMessageId()) {
/* 139 */       throw MailServiceException.IS_NOT_CHILD();
/*     */     }
/* 141 */     markItemDeleted();
/* 142 */     this.mMailbox.uncache(this);
/*     */   }
/*     */   
/*     */   public MailItem snapshotItem() throws ServiceException
/*     */   {
/* 147 */     MailItem.UnderlyingData data = getUnderlyingData().clone();
/* 148 */     data.setFlag(Flag.FlagInfo.UNCACHED);
/* 149 */     return new VirtualConversation(this.mMailbox, data);
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/mailbox/VirtualConversation.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */